<template>
	<el-container>
        <el-header>
            <div class="left-panel">
                <el-button type="primary" icon="el-icon-plus" @click="add"></el-button>
                <el-button type="danger" plain icon="el-icon-delete" :disabled="selection.length==0" @click="batch_del"></el-button>
            </div>
        </el-header>
        <el-main class="nopadding">
            <bydTable ref="table" :apiObj="apiObj" row-key="changeId" @selection-change="selectionChange" stripe border>
                <el-table-column type="selection" width="50"></el-table-column>
                <el-table-column label="序号" type="index" fixed width="50"></el-table-column>
                <el-table-column label="移交人" prop="getName" width="150"></el-table-column>
                <el-table-column label="地区" prop="place" min-width="100"></el-table-column>
                <el-table-column label="工厂/部门" prop="factory" width="150"></el-table-column>
                <el-table-column label="印章名称" prop="sealName" min-width="150"></el-table-column>
                <el-table-column label="印章规格"  prop="specifications" width="150"></el-table-column>
                <el-table-column label="原监印人"  prop="oldKeepName" width="150"></el-table-column>
                <el-table-column label="移交数量" prop="sealCount" width="100"></el-table-column>
                <el-table-column label="移交日期" prop="getDate" :formatter="formatGetDate" width="150"></el-table-column>
                <el-table-column label="移交原因" prop="getReason" width="150"></el-table-column>
                <el-table-column label="接收人" prop="receiveName" width="150"></el-table-column>
                <el-table-column label="处理日期" prop="receiveDate" :formatter="formatRcvDate" width="150"></el-table-column>
                <el-table-column label="印章图样" prop="sealPattern" width="150" fixed="right" align="center">
                    <template #default="scope">
                        <bydWaterMark ref="wm" text="印章管理系统" subtext="印章图样">
                        <el-image @click="handleLoad"
                                style="width: 120px; height: 80px" 
                                :preview-teleported="true" 
                                :src="scope.row.sealPattern" 
                                :fit="fit" 
                                :preview-src-list="[scope.row.sealPattern]">
                            </el-image>
                        </bydWaterMark>
                    </template>
                </el-table-column>
                <el-table-column label="状态" prop="state" width="100"></el-table-column>
            </bydTable>
        </el-main>
    </el-container>
</template>

<script>
	import { create } from '@/utils/watermark';
	import mmt from 'moment';

	export default {
		name: "changeRecord",
		components:{},
		data(){
			return {
				groupId: '0',
				apiObj: this.$api.infoConfirm.sealChangeRecord,
				selection: [],
				trackIdNow: '',
				pageType : 1,
			}
		},
		methods: {
			handleLoad() {
                setTimeout(() => {
                    const img = document.querySelector('.el-image-viewer__canvas');
                    var userInfo = this.$tool.data.get("USER_INFO");
                    create(img, { text: '印章管理系统',subtext : userInfo.username + userInfo.jobnumber })
                }, 100)
            },
			formatGetDate(row, column){
				return mmt(row.getDate).format('YYYY-MM-DD');
			},
            formatRcvDate(row, column){
                console.log(row.receiveDate)
                return mmt(row.receiveDate).format('YYYY-MM-DD');
            }
		}
	}
</script>

<style>
</style>
